package obecto.utility
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;

	[Event(name="enterFrame", type="flash.events.Event")]
	public class EnterFrameBeacon extends EventDispatcher
	{
		private static var _instance : EnterFrameBeacon;
		public static function get instance() : EnterFrameBeacon
		{
			if (_instance == null)
			{
				_instance = new EnterFrameBeacon();
			}
			return _instance;
		}
		
		private var sprite : Sprite;
		public function EnterFrameBeacon()
		{
			super();
			
			if (_instance != null)
			{
				throw new Error("Attempt to create another instance of EnterFrameBeacon.");
			}
			
			_instance = this;	
			sprite = new Sprite();
			sprite.addEventListener(Event.ENTER_FRAME, handleSpriteEnterFrame);
		}
		
		private function handleSpriteEnterFrame(event : Event) : void
		{
			dispatchEvent(new Event(Event.ENTER_FRAME));
		}
		
	}
}